/*
 * radio.h - FM radio GUI
 *
 * Copyright (C) 2010-2011 Serge Begger
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef RADIO_H
#define RADIO_H

#include <QWidget>
#include <QTimer>
#include <QEventLoop>
#include <QSettings>
#include <QPushButton>
#include <QProcess>
#include <QFile>
#include <QList>

#include <QThread>

#include "radiofunc.h"
#include "qcarpcdialog.h"
#include "gstengine.h"

namespace Ui {
    class Radio;
}

class Radio : public QWidget {
    Q_OBJECT
public:
    Radio(QWidget *parent = 0);
    ~Radio();
    bool initRadio();
    gstengine *gstEngine;
    int currVolume;
    void setVolume(int vol);

protected:
    void changeEvent(QEvent *e);

private:
    Ui::Radio *ui;
    radiofunc tuner;
    QTimer *timer;
    QTimer *scanTimer;
    QTimer *seekTimer;
    QPushButton *currButton;
    numPanel *freqPanel;    

    QList<float> *stationList1, *stationList2, *stationList3;
    int currBand, currStation, currSignal, count1, count2, count3, stationRange;
    float currFreq, min_freq, max_freq, currStep, range, startFreq;
    void seekStation();
    void startTimer();
    float returnFreq();
    void insertFreq();
    void saveStation();
    void loadStation();
    void resetCount();
    int stCount();
    void updateStButton();
    void setTunerFreq();
    QSettings *settings;
    QSettings *settingsGlobal;

signals:
    void hideWidget();

private slots:
    void on_backButton_pressed();
    void on_closeButton_pressed();
    void on_startScanButton_clicked();
    void on_seekLeftButton_pressed();
    void on_seekRightButton_pressed();
    void on_stationButton1_pressed();
    void on_stationButton2_pressed();
    void on_stationButton3_pressed();
    void on_stationButton4_pressed();
    void on_stationButton5_pressed();
    void on_stationButton6_pressed();
    void on_stationLeftButton_pressed();
    void on_stationRightButton_pressed();
    void on_setBandButton_pressed();
    void on_setFreqButton_pressed();
    void endTimer();
    void updateGUI();
    void updateUiFreq();
    void setManFreq();
    void startScan();
    void autoSeekStation();
};

#endif // RADIO_H
